package cn.regexp.elasticjob.mapper;

import cn.regexp.elasticjob.domain.SysJob;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface JobMapper {
    @Select("select * from sys_job where job_status = 1")
    List<SysJob> getRuningJob();

    @Select("select * from sys_job where id = #{id} limit 1")
    SysJob getById(long id);

    @Select("select * from sys_job where job_name = #{jobName} limit 1")
    SysJob getByJobName(@Param("jobName") String jobName);

    @Update("update sys_job set job_status = #{jobStatus} where id = #{id} limit 1")
    int updateStatusById(@Param("id") long id,@Param("jobStatus") int jobStatus);

    int save(SysJob job);

    int update(SysJob job);
}
